<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core">
    <style type="text/css">
        .tableStyle{
            margin:10px 0px 5px 0px;
        }
        .gridStyle{
            margin:10px 10px 10px 0px;
        }
        .gridStyle input{
            size:40px;
        }
        input{
            margin:1px 1px 1px 2px;
        }
        input[type='submit']{
            margin:3px 5px 3px 5px;
            padding:2px 5px 2px 5px;
        }
        .top{
            vertical-align: top;
            text-align:left;
        }
        .col1{
            width:100px;
        }
    </style>
    <h:form>
        <rich:panel header="项目" id="funPanel" styleClass="content-hight">
            <rich:messages globalOnly="true"/>
            <rich:toolbar id="tolbar">
                <rich:toolbarGroup>
                    <a4j:commandButton value="新增" execute="@this" render="tolbar,editGroup"
                                       action="#{projectBean.add}"/>
                    <a4j:commandButton value="修改" execute="@this" render="tolbar,editGroup"
                                       action="#{projectBean.update}"
                                       disabled="#{projectBean.addOrUpdate or empty projectBean.node}"/>
                    <a4j:commandButton value="保存" execute="@form" render="funPanel"
                                       action="#{projectBean.checkSave}"
                                       disabled="#{!projectBean.editStatus}"/>
                    <a4j:commandButton value="删除" execute="@form" render="funPanel"
                                       action="#{projectBean.delete}"
                                       disabled="#{projectBean.addOrUpdate or empty projectBean.node}"/>
                    <a4j:commandButton value="取消" execute="@this" render="tolbar,editGroup"
                                       action="#{projectBean.cancel}"/>
                </rich:toolbarGroup>
            </rich:toolbar>
            <h:panelGrid columns="2" width="100%" columnClasses="top,top">
                <h:panelGroup>
                    <div style="width:370px;height: 350px;overflow: auto;">
                        <rich:tree value="#{projectBean.rootNode}" var="idept"
                                   selectionType="ajax" toggleType="client"
                                   selectionChangeListener="#{projectBean.selected}"
                                   render="tolbar,editGroup">
                            <rich:treeNode>
                                <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                            </rich:treeNode>
                        </rich:tree>
                    </div>
                </h:panelGroup>
                <h:panelGroup id="editGroup">
                    <div style="width:370px;height: 350px;overflow: auto;">
                        <h:panelGrid columns="3" styleClass="gridStyle"
                                     columnClasses="col1,col2,col3"
                                     style="text-align:left">
                            <h:outputText value="编码："/>
                            <h:inputText disabled="#{!projectBean.addOrUpdate or !projectBean.editStatus}"
                                         id="code" value="#{projectBean.node.code}"/>
                            <rich:message for="code"/>
                            <h:outputText value="名称："/>
                            <h:inputText disabled="#{!projectBean.editStatus}"
                                         id="name" value="#{projectBean.node.name}"/>
                            <rich:message for="name"/>

                            <h:outputText value="所属部门："/>
                            <h:inputText disabled="#{!projectBean.editStatus}"
                                         id="department"
                                         value="#{projectBean.node.deptName}"
                                         onclick="#{rich:component('deptPanel')}.show();"/>
                            <rich:message for="department"/>

                            <h:outputText value="所属财政项目："/>
                            <h:inputText disabled="#{!projectBean.editStatus}"
                                         id="finProjCode"
                                         onclick="#{rich:component('finProjPanel')}.show();"
                                         value="#{projectBean.node.finProjName}"/>
                            <rich:message for="finProjCode"/>

                            <h:outputText value="负责人："/>
                            <h:inputText disabled="#{!projectBean.editStatus}"
                                         id="manager" 
                                         value="#{projectBean.node.managerName}"
                                         onclick="#{rich:component('personPanel')}.show();"/>
                            <rich:message for="manager"/>

                            <h:outputText value="开始日期："/>
                            <rich:calendar value="#{projectBean.node.beginDate}"
                                           disabled="#{!projectBean.editStatus}" 
                                           locale="zh_CN"
                                           required="true"
                                           requiredMessage="不能为空！"
                                           popup="true"
                                           id="startDate" 
                                           datePattern="yyyy-MM-dd"
                                           showApplyButton="false"
                                           style="width:200px">
                            </rich:calendar>
                            <rich:message for="startDate"/>

                            <h:outputText value="结束日期："/>
                            <rich:calendar value="#{projectBean.node.endDate}"
                                           disabled="#{!projectBean.editStatus}" 
                                           locale="zh_CN"
                                           popup="true"
                                           required="true"
                                           requiredMessage="不能为空！"
                                           id="endDate" 
                                           datePattern="yyyy-MM-dd"
                                           showApplyButton="false"
                                           style="width:200px">
                            </rich:calendar>
                            <rich:message for="endDate"/>

                            <h:outputText value="备注："/>
                            <h:inputText disabled="#{!projectBean.editStatus}" id="memo" value="#{projectBean.node.memo}"/>
                            <rich:message for="memo"/> 
                        </h:panelGrid>
                    </div>
                </h:panelGroup>
            </h:panelGrid>
        </rich:panel>
    </h:form>

    <rich:popupPanel id="deptPanel" autosized="true">
        <f:facet name="header">部门</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#"
                          onclick="#{rich:component('deptPanel')}.hide();
                                                 return false;">关闭</h:outputLink>
        </f:facet>
        <rich:panel>
            <h:form>
                <div style="width:300px;min-height:280px;overflow:auto;">
                    <rich:tree value="#{departmentBean.rootNode}" var="idept"
                               selectionType="ajax" toggleType="client"
                               selectionChangeListener="#{projectBean.deptTreeSelected}"
                               style="width:300px">
                        <rich:treeNode>
                            <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                        </rich:treeNode>
                    </rich:tree>
                </div>
                <a4j:commandButton value="确定"
                                   onclick="#{rich:component('deptPanel')}.hide();"
                                   render="department"/>
            </h:form>
        </rich:panel>
    </rich:popupPanel>
    <rich:popupPanel id="finProjPanel" autosized="true">
        <f:facet name="header">财政项目</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#"
                          onclick="#{rich:component('finProjPanel')}.hide();
                                                 return false;">关闭</h:outputLink>
        </f:facet>
        <rich:panel>
            <h:form>
                <div style="width:300px;max-height:380px;overflow:auto;">
                    <rich:dataTable value="#{finProjBean.finModel}" var="pro"
                                    onrowmouseover="this.style.backgroundColor='#F1F1F1'"
                                    onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                                    rowClasses="list-row-odd,list-row-even" styleClass="tableStyle">
                        <rich:column style="min-width:60px;">
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="编码"/>
                                </h:panelGroup>
                            </f:facet>
                            <a4j:commandLink actionListener="#{projectBean.finProjSelected(pro)}"
                                             execute="@this" render="finProjCode"
                                             oncomplete="#{rich:component('finProjPanel')}.hide()">
                                <h:outputText value="#{pro.finCode}"/>
                            </a4j:commandLink>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:panelGroup>
                                    <h:outputText value="名称"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{pro.finName}"/>
                        </rich:column>
                        <rich:column style="min-width:60px;">
                            <f:facet name="header">
                                <h:panelGroup style="white-space: nowrap">
                                    <h:outputText value="备注"/>
                                </h:panelGroup>
                            </f:facet>
                            <h:outputText value="#{pro.memo}"/>
                        </rich:column>
                    </rich:dataTable> 
                </div>
            </h:form>
        </rich:panel>
    </rich:popupPanel>

    <rich:popupPanel id="personPanel" autosized="true">
        <f:facet name="header">负责人</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#"
                          onclick="#{rich:component('personPanel')}.hide();
                                                 return false;">关闭</h:outputLink>
        </f:facet>
        <rich:panel>
            <h:form>
                <div style="width:700px;min-height:280px;overflow:auto;">
                    <h:panelGrid columns="2" width="100%" border="0" rowClasses="treeRow" columnClasses="top,top">
                        <h:panelGroup>
                            <rich:tree value="#{departmentBean.rootNode}" var="idept"
                                       selectionType="ajax" toggleType="client"
                                       selectionChangeListener="#{personBean.treeSelected}"
                                       style="width:200px" render="tableGroup">
                                <rich:treeNode>
                                    <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                                </rich:treeNode>
                            </rich:tree>
                        </h:panelGroup>
                        <h:panelGroup id="tableGroup">
                            <rich:dataScroller for="personinfo" execute="@this" render="tableGroup"/>
                            <div style="width: 400px;overflow:auto;">
                                <rich:dataTable  value="#{personBean.personModel}" var="person"
                                                 style="width:100%;"
                                                 rows="10"
                                                 id="personinfo">
                                    <f:facet name="header">
                                        <h:outputText value="部门人员信息" />
                                    </f:facet>
                                    <rich:column>
                                        <f:facet name="header">
                                            <h:panelGroup>
                                                <h:outputText value="人员代码"/>
                                            </h:panelGroup>
                                        </f:facet>
                                        <a4j:commandLink value="#{person.cpsn_number}"
                                                         action="#{projectBean.personSelected(person)}"
                                                         execute="@this"
                                                         render="manager"
                                                         oncomplete="#{rich:component('personPanel')}.hide();">
                                        </a4j:commandLink>
                                    </rich:column>
                                    <rich:column >
                                        <f:facet name="header">
                                            <h:panelGroup>
                                                <h:outputText value="人员姓名"/>
                                            </h:panelGroup>
                                        </f:facet>
                                        <h:outputText  value="#{person.cpsn_name}" />
                                    </rich:column>                                  
                                </rich:dataTable>
                            </div>
                        </h:panelGroup>
                    </h:panelGrid>
                </div>
            </h:form>
        </rich:panel>
    </rich:popupPanel>
</html>
